package com.aurora.source.center.presenter;

import android.content.Context;

import com.aurora.source.base.BaseBean;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.center.bean.OprationRecoredListBean;
import com.aurora.source.center.view.IOperationRecoredView;
import com.aurora.source.constant.AuroraConstants;
import com.aurora.source.util.netutil.SubscriberObserver;

import java.util.HashMap;
import java.util.Map;


/**
 * @author: ww
 * @description:流程操作记录
 * @date: 2018/9/29
 */
public class OperationRecoredPresenter extends BasePresenter<IOperationRecoredView>{
    public OperationRecoredPresenter(IOperationRecoredView baseView) {
        super(baseView);
    }

    public void queryRecordingList(Map<String, String> params) {
        requestMethod.queryRecordingList(params, new SubscriberObserver<BaseBean<OprationRecoredListBean>>((Context) baseView, "数据加载中...") {
            @Override
            public void onSuccess(BaseBean<OprationRecoredListBean> baseBean) {
                if(baseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)){
                    baseView.onGetRecoredSuccess(baseBean.getData().getRecordingList());
                }else {
                    baseView.onGetRecoredFail(baseBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onGetRecoredFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }

    public void finishFlow(String parentId,String batchTitle) {
        Map<String,String> params = new HashMap<>();
        params.put("parentId",parentId);
        params.put("batchTitle",batchTitle);
        requestMethod.finishFlow(params, new SubscriberObserver<BaseBean>((Context) baseView, "数据请求中...") {
            @Override
            public void onSuccess(BaseBean baseBean) {
                if(baseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)){
                    baseView.onFinishFlowSuccess(baseBean.getMsg());
                }else {
                    baseView.onFinishFlowFail(baseBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onFinishFlowFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }
}
